package com.ruoyi.center.domain;

import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 依托与共建单位对象 tb_affiliated_unit
 *
 * @author ruoyi
 * @date 2025-11-08
 */
public class AffiliatedUnit extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** ID */
    private Long id;

    /** 单位名称 */
    @Excel(name = "单位名称")
    private String unitName;

    /** 单位类型 */
    @Excel(name = "单位类型")
    private String type;

    /** 单位简介 */
    @Excel(name = "单位简介")
    private String introduction;

    /** 支撑资源 */
    @Excel(name = "支撑资源")
    private String supportResources;

    /** 联系方式 */
    @Excel(name = "联系方式")
    private String contactInfo;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }

    public void setUnitName(String unitName)
    {
        this.unitName = unitName;
    }

    public String getUnitName()
    {
        return unitName;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getType()
    {
        return type;
    }

    // 为前端提供unitType别名
    @JsonProperty("unitType")
    public String getUnitType()
    {
        return type;
    }

    public void setUnitType(String unitType)
    {
        this.type = unitType;
    }

    public void setIntroduction(String introduction)
    {
        this.introduction = introduction;
    }

    public String getIntroduction()
    {
        return introduction;
    }

    // 为前端提供description别名（合并introduction和supportResources）
    @JsonProperty("description")
    public String getDescription()
    {
        StringBuilder desc = new StringBuilder();
        if (introduction != null && !introduction.isEmpty()) {
            desc.append(introduction);
        }
        if (supportResources != null && !supportResources.isEmpty()) {
            if (desc.length() > 0) {
                desc.append("<br/><br/><strong>支撑资源：</strong><br/>");
            }
            desc.append(supportResources);
        }
        return desc.toString();
    }

    public void setDescription(String description)
    {
        // 当admin端传入description时，存储到introduction字段
        this.introduction = description;
    }

    public void setSupportResources(String supportResources)
    {
        this.supportResources = supportResources;
    }

    public String getSupportResources()
    {
        return supportResources;
    }

    public void setContactInfo(String contactInfo)
    {
        this.contactInfo = contactInfo;
    }

    public String getContactInfo()
    {
        return contactInfo;
    }

    public void setCreateTime(Date createTime)
    {
        this.createTime = createTime;
    }

    public Date getCreateTime()
    {
        return createTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("unitName", getUnitName())
                .append("type", getType())
                .append("introduction", getIntroduction())
                .append("supportResources", getSupportResources())
                .append("contactInfo", getContactInfo())
                .append("createTime", getCreateTime())
                .toString();
    }
}